package main

import (
	"fmt"
	"strconv"
	"time"
)

func test() {
	for i:=1;i<=5;i++{
		fmt.Print("test运行。。。"+strconv.Itoa(i), "\n")
		time.Sleep(time.Second)
	}
}

func test1() {
	// defer-recover异常捕获
	defer func() {
		if err := recover(); err != nil{
			fmt.Println("test1()异常", err)
		}
	}()
	for i:=1;i<=5;i++{
		var m map[int]int
		m[0] = 0  // error，没有进行make
		fmt.Print("test1运行。。。"+strconv.Itoa(i), "\n")
		time.Sleep(time.Second)
	}
}

func main() {
	go test()  // 开启了一个协程
	go test1()  // 开启了一个协程
	for i:=1;i<=5;i++{
		fmt.Print("main运行。。。"+strconv.Itoa(i), "\n")
		//time.Sleep(time.Second)
	}
}